/*-----------------------------------------------------------------------------
Archivo:      test_cu.c
Autor:	      Cesar Armando Fuguet Tortolero
	          Debe compilarse con la herramienta genpat.
------------------------------------------------------------------------------*/

#include <stdio.h>
#include "genpat.h"

char* inttostr(int entier) {
    char* str;
    str = (char *) mbkalloc (32 * sizeof(char));
    sprintf(str,"%d",entier);
    return(str);
}

main() {

    DEF_GENPAT("test_counter");
    
    DECLAR("CLK_i"          ,":2","B", IN   ,	      ""      , "");
    DECLAR("RESET_i"        ,":2","B", IN   ,	      ""      , "");
    DECLAR("COUNTER_o"      ,":2","B", OUT  ,	"1 downto 0"  , "");
    DECLAR("VDD"            ,":2","B", IN   ,	      ""      , "");
    DECLAR("VSS"            ,":2","B", IN   ,	      ""      , "");

    LABEL("cu");

    SETTUNIT("ns");
    AFFECT("0", "VDD"	    , "1"       ); 
    AFFECT("0", "VSS"	    , "0"       );
    AFFECT("0", "CLK_i"	    , "1"       );
    AFFECT("0", "RESET_i"   , "1"       );

    AFFECT("50", "CLK_i"	   , "0"      );
    AFFECT("100", "CLK_i"	   , "1"      );
    AFFECT("125", "RESET_i"    , "0"      );

    int i;
    for(i=1; i<24; i++) {
        AFFECT("+50"    , "CLK_i"   , inttostr(i%2));
    }

    SAV_GENPAT();

    exit(0);
}

/* vim: tabstop=4 : expandtab : shiftwidth=4
*/
